#include <iostream>
using namespace std;

class Person
{
  friend ostream &operator<<(ostream &cout, Person &p);

public:
  Person(int a, int b)
  {
    m_a = a;
    m_b = b;
  }

private:
  int m_a;
  int m_b;

  // 利用成员函数重载 左移运算符 p.operator<<(cout) 简化版本 p << cout
  // 不会利用成员函数重载左移运算符，因为无法实现cout在左侧
  // void operator<< ()
};

// 只能利用全局函数重载左移运算符
ostream &operator<<(ostream &cout, Person &p) // 本质 operator<< (cout, p) 简化 cout << p
{
  cout << "m_a = " << p.m_a << "\tm_b = " << p.m_b;

  return cout;
}

void test01()
{
  Person p(10, 10);

  cout << p << endl;
}

int main(int argc, char const *argv[])
{
  test01();

  return 0;
}